public class Solution1 {
    public String removeDuplicates(String ss) {
        StringBuffer ret = new StringBuffer(); // 用数组模拟栈结构
        char[] s = ss.toCharArray();
        ret.append(s[0]);
        for(int i = 1; i < s.length; i++) {
            if(ret.length() > 0 && s[i] == ret.charAt(ret.length() - 1)) {
                // 出栈
                ret.deleteCharAt(ret.length() - 1);
            }else {
                ret.append(s[i]);
            }
        }
        return ret.toString();
    }
}
